<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pretty="http://ocpsoft.com/prettyfaces"
	xmlns:security="http://www.springframework.org/security/facelets/tags"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition>
	<security:isAuthenticated>
		<h:panelGroup id="newOrder"
			rendered="#{empty companyDetailsBean.activeOrders}">
			<div class="box" id="order">
				<h2>
					<a id="toggle-order" href="#"> <h:outputFormat
							value="#{msg['companydetails.newOrder']}">
							<f:param value="#{companyDetailsBean.company.name}" />
							<f:param value="#{companyDetailsBean.shareValue}" />
						</h:outputFormat>
					</a>
				</h2>
				<div id="order" class="block paragraphs">
					<h:form prependId="false">
						<div id="top" style="width: 100%">
							<p:messages autoUpdate="true" showDetail="true"
								showSummary="false" />

							<div id="top_left" style="width: 50%; float: left;">
								<table cellspacing="3" cellpadding="3" border="0"
									style="margin-right: 10px;">
									<thead>
										<tr>
											<th class="table-head" colspan="2"><h:outputText
													value="#{msg['companydetails.orderType']}" /></th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.offerType']}" /></td>
											<td><p:selectOneMenu id="transaction"
													value="#{companyDetailsBean.transactionType}"
													required="true"
													label="#{msg['companydetails.transactionType']}"
													style="width: 100%;">
													<f:selectItems
														value="#{companyDetailsBean.transactionTypes}" />
												</p:selectOneMenu></td>
										</tr>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.sharesAmount']}" /></td>
											<td><p:inputText id="amount" required="true"
													value="#{companyDetailsBean.amount}"
													label="#{msg['companydetails.sharesAmount']}" /></td>
										</tr>
									</tbody>
								</table>
								<table cellspacing="3" cellpadding="3" border="0"
									style="margin-right: 10px; margin-top: 10px;">
									<thead>
										<tr>
											<th class="table-head" colspan="2"><h:outputText
													value="#{msg['companydetails.offerrType2']}" /></th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td style="text-align: left;"><h:selectBooleanCheckbox
													id="type1" value="#{companyDetailsBean.typeOne}"
													onchange="clickFirst()" /> <h:outputText
													value="#{msg['companydetails.priceLimit']}" /></td>
											<td><p:inputText id="type1input"
													value="#{companyDetailsBean.priceOne}" required="false"
													label="#{msg['companydetails.priceLimit']}" /></td>
										</tr>
										<tr>
											<td style="text-align: left;"><h:selectBooleanCheckbox
													id="type2" value="#{companyDetailsBean.typeTwo}"
													onchange="clickSecond()" /> <h:outputText
													value="#{msg['companydetails.pkc']}" /></td>
											<td></td>
										</tr>
										<tr>
											<td style="text-align: left;"><h:selectBooleanCheckbox
													id="type3" value="#{companyDetailsBean.typeThree}"
													onchange="clickThird()" /> <h:outputText
													value="#{msg['companydetails.stopLoss']}" /></td>
											<td><p:inputText id="type3input"
													value="#{companyDetailsBean.priceThree}" required="false"
													label="#{msg['companydetails.stopLoss']}" /></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div id="top_right" style="width: 50%; float: right;">
								<table cellspacing="3" cellpadding="3" border="0"
									style="margin-left: 10px; margin-right: 10px;">
									<thead>
										<tr>
											<th class="table-head" colspan="2">Dane</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.maxPurchase']}" /></td>
											<td><h:outputText
													value="#{companyDetailsBean.canBuyAmount}" /></td>
										</tr>
										<h:panelGroup
											rendered="#{! empty companyDetailsBean.canSellAmount}">
											<tr>
												<td><h:outputText
														value="#{msg['companydetails.maxSell']}" /></td>
												<td><h:outputText
														value="#{companyDetailsBean.canSellAmount}" /></td>
											</tr>
										</h:panelGroup>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.sharePriceCurrency']}" /></td>
											<td><h:outputText id="sharePrice"
													value="#{companyDetailsBean.sharePrice}" /></td>
										</tr>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.commissionValue']}" /></td>
											<td><h:outputText
													value="#{companyDetailsBean.commissionPercentage}" /></td>
										</tr>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.commissionTotal']}" /></td>
											<td><h:outputText id="commissionValue"
													value="#{companyDetailsBean.commissionValue}" /></td>
										</tr>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.transactionTotal']}" /></td>
											<td><span id="transactionValue" /></td>
										</tr>
										<tr>
											<td><h:outputText
													value="#{msg['companydetails.expiryDate']}" /></td>
											<td><p:inputText id="date" required="true"
													value="#{companyDetailsBean.expiryDate}"
													label="#{msg['companydetails.expiryDate']}"
													style="width: 100px;">
													<f:convertDateTime pattern="dd-MM-yyyy" />
												</p:inputText></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div style="width: 100%">
								<p:commandButton id="orderButton"
									action="#{companyDetailsBean.saveOrder}"
									binding="#{companyDetailsBean.button}"
									value="#{msg['companydetails.buttonConfirm']}"
									style="width: 100%;">
									<p:ajax process="@form" update="@form" />
								</p:commandButton>
							</div>

							<h:outputText id="originalSharePrice"
								value="#{companyDetailsBean.shareValue}"
								style="visibility: hidden;" />
						</div>
					</h:form>
				</div>
			</div>
		</h:panelGroup>
	</security:isAuthenticated>
</ui:composition>

</html>
